const {
    Mysql,
    TripleEncrypt
} = require('../tools');
module.exports = async ctx => {
    let {
        vid
    } = ctx.query;
    try {
        if (vid == undefined || isNaN(Number(vid))) {
            ctx.state.data = {
                code: '002',
                msg: '参数错误'
            }
            return;
        } else {
            let sql = `SELECT
                orderList.money,
                userInfo.user_info
            FROM
                orderList
            RIGHT JOIN userInfo ON orderList.openId = userInfo.open_id
            WHERE
                orderList.vid = ${Number(vid)}
            AND orderList.type = 'ADMIRE'
            ORDER BY
                orderList.create_time DESC
            LIMIT 21`
            let res = await Mysql(sql);
            ctx.state.data = {
                code: '001',
                data: TripleEncrypt(JSON.stringify(res))
            }
        }
    } catch (error) {
        throw error
        ctx.state.data = {
            code: '002',
            msg: '内部错误'
        }
    }
};